<template>
    <Form :label-width="120" inline class="selectupload">
        <compFormEdit
            ref="formdata"
            class="margin-10"
            v-if="getBase&&getBase.length"
            :formdata="getBase"
            v-model="formData"
        ></compFormEdit>
        <div class="color-error margin-bottom-10">{{warningtitle}}</div>
        <compUpload v-bind="getFileProps" @on-close="close" @on-success="success" ></compUpload>
        
    </Form>
</template>

<script>
export default {
    props:{
        name: String, 
        formdata: Array,
        actionurl: String,
        downrul: String,
        warningtitle: String, 
        localurl:Boolean,
        showdownload:Number,
        id:String,
        params:null,
    },
    components: {
        compFormEdit: () => import("@components/templates/formedit"),
		compUpload: () => import("@components/templates/upload"),
	},
    data(){
        return {
            formData:{...this.params}
        }
    },
    computed: {
        getBase(){
            return this.formdata
        },
        getFileProps() {
            if(this.showdownload === 1){
                return {
                    action: global.APIURL_HOST + this.actionurl,
                    name: this.name,
                    data: {
                        id:this.id?this.id:'',
                        contextId:global.SYSID,
                        ...this.formData
                    },
                }
            }else{
                return {
                    action: global.APIURL_HOST + this.actionurl,
                    name: this.name,
                    data: {
                        id:this.id?this.id:'',
                        contextId:global.SYSID,
                        ...this.formData
                    },
                    download:()=>{
                        
                    }
                }
            }
		},
    },
    methods:{
        close(){
            this.$emit('on-close')
        },
        success(){
            this.$emit('on-update')
            this.close()
        }
    }


}
</script>
